﻿<?xml version="1.0" encoding="utf-8" ?>
<Batch 
    xmlns="http://schemas.dbshell.com/core"
    xmlns:rds="http://schemas.dbshell.com/datasync"
    >
    <rds:SyncModel >
        <rds:SyncModel.Sources>
            <rds:Source DataSource="{Table Continent}" Alias="src_continent">
                <rds:SourceColumn Name="ContinentName" IsKey="True" />
            </rds:Source>
            <rds:Source DataSource="{Table Country}">
                <rds:SourceColumn Name="CountryCode" IsKey="True" />
                <rds:SourceColumn Name="CountryName"  />
                <rds:SourceColumn Name="ContinentName" />
            </rds:Source>
            <rds:Source DataSource="{Table City}">
                <rds:SourceColumn Name="CityName" IsKey="True" />
                <rds:SourceColumn Name="CountryCode"  />
                <rds:SourceColumn Name="CityCitizens" />
            </rds:Source>
            <rds:Source DataSource="{Table CityPart}">
                <rds:SourceColumn Name="CityPartName" IsKey="True" />
                <rds:SourceColumn Name="CityName"  />
            </rds:Source>
        </rds:SyncModel.Sources>

        <rds:SyncModel.Targets>

            <rds:Target TableName="TargetCityPartByContinentList">
                <rds:TargetColumn Name="Name" Source="CityPartName" IsKey="True"/>
            </rds:Target>

            <rds:Target TableName="TargetCountryList">
                <rds:TargetColumn Name="Name" Source="CountryName" IsKey="True"/>
            </rds:Target>

            <rds:Target TableName="TargetCityList">
                <rds:TargetColumn Name="Name" Source="CityName" IsKey="True"/>
            </rds:Target>

            <rds:Target TableName="TargetCityPartList">
                <rds:TargetColumn Name="Name" Source="CityPartName" IsKey="True"/>
            </rds:Target>

            <rds:Target TableName="TargetContinentList">
                <rds:TargetColumn Name="Name" Source="ContinentName" IsKey="True"/>
            </rds:Target>

        </rds:SyncModel.Targets>
        <rds:SyncModel.TargetReferences>
            <rds:TargetReference Source="TargetCityPartByContinentList" Target="TargetContinentList">
                <rds:TargetReferenceColumn BaseName="ID_CONTINENT" RefName="ID" />
            </rds:TargetReference>

            <rds:TargetReference Source="TargetCountryList" Target="TargetContinentList" IsKey="True">
                <rds:TargetReferenceColumn BaseName="ID_CONTINENT" RefName="ID" />
            </rds:TargetReference>

            <rds:TargetReference Source="TargetCityList" Target="TargetCountryList" IsKey="True">
                <rds:TargetReferenceColumn BaseName="ID_COUNTRY" RefName="ID" />
            </rds:TargetReference>

            <rds:TargetReference Source="TargetCityPartList" Target="TargetCityList" IsKey="True">
                <rds:TargetReferenceColumn BaseName="ID_CITY" RefName="ID" />
            </rds:TargetReference>
        </rds:SyncModel.TargetReferences>
    </rds:SyncModel>
    
    <rds:CreateProcedure ProcName="RunSync1" />
    <rds:CreateProcedure ProcName="RunSync2" />

    <!--
    <rds:Run />
    -->
    <rds:Run />
</Batch>
